var jQ = jQuery.noConflict();
jQ(document).ready(function(){
	jQ(".module.aligned input, .module.aligned select").live("change", function(){
		var fieldset = jQ(this).parent().parent().parent();
		var kol = jQ(fieldset.find("input")[0]);
		var sum = jQ(fieldset.find("input")[1]);
		var product = jQ(fieldset.find("select"));
		var JSONObj = {id: product.val(), kol: kol.val(), price: "price"}
		var csrf = jQ("input[name=csrfmiddlewaretoken]");
		if( kol.val() != "" && product.val() != ""){
			jQ.ajax({
					url: "/shop/get_sum_product/",
					type: "POST",
					data: {csrfmiddlewaretoken: csrf.val(), product: JSON.stringify(JSONObj)}, 
					async: false,
					success: function (data){
						var result = JSON.parse(data);
						if (result.status == "ok"){
							sum.val(result.sum);
						}
					}
				});
			}
	});
});